package com.csair.irp.job.file.parser.autogateway;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.csair.irp.job.file.task.DispatchLogPO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @Auther: liaolonglong
 * @Date: 2018/12/19 10:47
 * @Description:网关自动对接参数配置表
 */
public interface AutodockingRelationshipMapper extends BaseMapper<AutodockingRelationshipPO> {

    /**
     * 更新网关自动对接调度任务信息
     *
     * @param etlState        调度任务状态
     * @param businessNumber  网关商户号
     * @param transactionDate 网关交易日期
     * @param totalAmount     总交易金额
     * @param dispatchTime    解析时长
     * @param resourceIds     关联文件ID
     */
    void updateAutoGatewayState(@Param("etlState") int etlState, @Param("businessNumber") String businessNumber, @Param("transactionDate") String transactionDate, @Param("totalAmount") BigDecimal totalAmount, @Param("dispatchTime") double dispatchTime, @Param("resourceIds") String resourceIds);

    List<DispatchLogPO> getAutoGatewayDispatchLog(@Param("gatewayCode") String gatewayCode, @Param("transactionDate") Date transactionDate, @Param("state") int etlState);

    List<String> getGatewaySuccessInfoByGatewaycode(@Param("gatewayCode") String gatewayCode, @Param("transactionDate") Date transactionDate);

    void updateMixAutoGatewayState(@Param("etl_state") int etl_state, @Param("gateway_code") String gateway_code, @Param("transaction_date") String transaction_date);

    String getGatewayCodebyBusinessNumber(@Param("businessNumber") String businessNumber);


    void updateComeGatewayState(@Param("etl_state") int etl_state, @Param("business_number") String business_number, @Param("transaction_date") String transaction_date);

    /**
     * 获取与该商户号相同网关的所有商户号
     *
     * @param gatewayCode
     * @return
     */
    @Select("SELECT distinct business_number FROM t_autodocking_relationship WHERE gateway_code=#{gatewayCode}")
    List<String> getBusinessNumbersByGatewayCode(String gatewayCode);

    /**
     * 根据fileBaseinfoId获取商户号
     *
     * @param fileBaseinfoId
     * @return
     */
    String getBusinessNumberByFileBaseinfoId(@Param("fileBaseinfoId") Long fileBaseinfoId);
}
